package cn.net.msg.dao.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import cn.net.msg.dao.TbMoodDao;
import cn.net.msg.model.TbMood;
import cn.net.msg.service.base.DaoSupport;
import cn.net.msg.service.base.Order;

@Component("tbMoodDao")
public class TbMoodDaoImpl extends DaoSupport implements TbMoodDao {

    private static final Log log = LogFactory.getLog(TbMoodDaoImpl.class);

    @Override
    public List<TbMood> getMoodForList(int firstIndex,
            int maxResult,Order order, String propertyName) {
        return super.paging(TbMood.class, firstIndex, maxResult, null, order, propertyName);
    };

    @Override
    public void addMood(TbMood tbMood) {
        super.save(tbMood);
    }

    @Override
    public void addMoodPraise(TbMood tbMood) {
        String hql = "update TbMood m set m.moodPraiseCount = ? where m.moodId = ? ";
        List<Object> params = new ArrayList<Object>();
        params.add(tbMood.getMoodPraiseCount());
        params.add(tbMood.getMoodId());
        super.executNonQuery(hql, params);
    }

    @Override
    public void addMoodBelittle(TbMood tbMood) {
        String hql = "update TbMood m set m.moodBelittleCount = ? where m.moodId = ? ";
        List<Object> params = new ArrayList<Object>();
        params.add(tbMood.getMoodBelittleCount());
        params.add(tbMood.getMoodId());
        super.executNonQuery(hql, params);
    }

    @Override
    public List<TbMood> getUserMoodForList(int firstIndex,
            int maxResult,List<HashMap<String,Object>> queryParams, Order order, String propertyName) {
        // TODO Auto-generated method stub
        return super.paging(TbMood.class, firstIndex, maxResult, queryParams, order, propertyName);
    }
}
